using System;
using UnityEngine;
using Unity.VisualScripting;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Play Sound")]
    [UnitSurtitle("Success")]
    public sealed class PlaySoundSuccess : FrameworkEventUnit<PlaySoundSuccessEventArgs>
    {
        protected override int EventId => PlaySoundSuccessEventArgs.EventId;
        protected override string HookName => UGFHookNames.PlaySoundSuccess;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SerialId
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SoundAssetName
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SoundAgent
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Duration
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput BindingEntity
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            SerialId = ValueOutput<int>(nameof(SerialId));
            SoundAssetName = ValueOutput<string>(nameof(SoundAssetName));
            SoundAgent = ValueOutput<GameFramework.Sound.ISoundAgent>(nameof(SoundAgent));
            Duration = ValueOutput<float>(nameof(Duration));
            BindingEntity = ValueOutput<Entity>(nameof(BindingEntity));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, PlaySoundSuccessEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(SerialId, args.SerialId);
            flow.SetValue(SoundAssetName, args.SoundAssetName);
            flow.SetValue(SoundAgent, args.SoundAgent);
            flow.SetValue(Duration, args.Duration);
            flow.SetValue(BindingEntity, args.BindingEntity);
            flow.SetValue(UserData, args.UserData);
        }
    }
}